<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<!--用户任务-->
<div class="easyui-layout" data-options="fit:true">
	<div
		data-options="region:'west',iconCls:'icon-product-design',title:'任务表单',split:false,border:false"
		style="width: 500px;">
		<form id="dom_formactrutask">
			<input type="hidden" name="ids" value="${ids}">
			<table class="editTable">
				<jsp:include page="easyUiFormParse.jsp"></jsp:include>
			</table>
		</form>
	</div>
	<div
		data-options="region:'center',iconCls:'icon-product-design',title:'流程图',border:false">
		<div style="margin: 8px;">
			<img src="admin/loadBpmInstanceImgfile.do?ids=${executionId}&taskIs=${ids}"
				width="100%" />
		</div>
	</div>
	<div data-options="region:'south'" style="height: 40px;">
		<div class="div_button" style="text-align: center; padding: 4px;">
			<a id="task_doButton_submit" href="javascript:void(0)"
				iconCls="icon-finished-work" class="easyui-linkbutton"
				style="color: #000000;">完成提交</a>
			<a id="task_doButton_save" href="javascript:void(0)"
				iconCls="icon-save" class="easyui-linkbutton"
				style="color: #000000;">保存</a>
			<a id="task_doButton_out" href="javascript:void(0)"
				iconCls="icon-sign-out" class="easyui-linkbutton"
				style="color: #000000;">取消</a>
			<c:if test="${onlyone}">
				<a id="dom_do_del" href="javascript:void(0)"
					data-options="plain:true" iconCls="icon-cancel"
					class="easyui-linkbutton" style="color: gray;">删除</a>
			</c:if>
			<c:if test="${haveCandidate}">
				<a id="dom_do_unclaim" href="javascript:void(0)"
					data-options="plain:true" iconCls="icon-control-stop"
					class="easyui-linkbutton" style="color: gray;">放弃办理</a>
			</c:if>
				<a id="dom_do_setAssignee" href="javascript:void(0)"
					data-options="plain:true" iconCls="icon-customers"
					class="easyui-linkbutton" style="color: gray;">移交</a>
		</div>
	</div>
</div>
<div id="win_AloneUser_ChoosPop" class="easyui-window" style="width: 500px; height: 350px;"
	data-options="closed:true,modal:true,href:'admin/AloneUser_ACTION_ALERT.do'"></div>
<script type="text/javascript">
	var submitAddActionactrutask = 'admin/ActRuTaskaddCommit.do';
	var submitEditActionactrutask = 'admin/ActRuTaskeditCommit.do';
	var currentPageTypeactrutask = '${pageset.pageType}';
	var submitFormactrutask;
	$(function() {
		//表单组件对象
		submitFormactrutask = $('#dom_formactrutask').SubmitForm( {
			pageType : currentPageTypeactrutask,
			grid : gridactrutask,
			currentWindowId : 'winactrutask'
		});
		//关闭窗口
		$('#task_doButton_out').bind('click', function() {
			$('#winactrutask').window('close');
		});
		//保存表单
		$('#task_doButton_save').bind('click', function() {
			submitFormactrutask.postSubmit("admin/ActRuTaskeditCommit.do");
		});
		//提交任务
		$('#task_doButton_submit').bind(
				'click',
				function() {
					submitFormactrutask.postSubmit(
							"admin/ActRuTaskSubmitCommit.do", function(flag) {
								$('#winactrutask').window('close');
								$(gridactrutaskWaiting).datagrid('reload');
								return false;
							});
				});
		
		//删除任务
		$('#dom_do_del').bind(
				'click',
				function() {
					$.messager.confirm("删除提示","是否要删除该任务?", function(flag) {
						if (flag) {
							$.post("admin/ActRuExecutiondeleteCommit.do" + '?ids=${executionId}',{},
									function(flag) {
										if (flag.pageset.commitType == 0) {
											$(gridactrutask).datagrid('reload');
											$('#winactrutask').window('close');
										} else {
											var str = MESSAGE_PLAT.ERROR_SUBMIT
													+ flag.pageset.message;
											$.messager.alert(MESSAGE_PLAT.ERROR, str,
													'error');
										}
									});
						}
					});
				});
		//移交任务
		$('#dom_do_setAssignee').bindChooseWindow('chooseWinactreprocdef', {
			width : 600,
			height : 300,
			modal : true,
			url : 'admin/AloneUser_ACTION_ALERT.do',
			title : '选择',
			callback : function(rows) {
				$.messager.confirm("提示","是否要移交任务给该用户?", function(flag) {
					if (flag) {
						$.post("admin/ActRuTaskSetAssignee.do" + '?ids=${ids}',{id:rows[0].ID},
								function(flag) {
									if (flag.pageset.commitType == 0) {
										$(gridactrutask).datagrid('reload');
										//$(gridactrutaskWaiting).datagrid('reload');
										$('#winactrutask').window('close');
									} else {
										var str = MESSAGE_PLAT.ERROR_SUBMIT
												+ flag.pageset.message;
										$.messager.alert(MESSAGE_PLAT.ERROR, str,
												'error');
									}
								});
					}
				});
			}
		});
		//提交任务
		$('#dom_do_unclaim').bind(
				'click',
				function() {
					$.messager.confirm("提示","是否要放弃该任务（可以在待办任务中重新领取）?", function(flag) {
						if (flag) {
							$.post("admin/ActRuTaskUnClaim.do" + '?ids=${ids}',{},
									function(flag) {
										if (flag.pageset.commitType == 0) {
											$(gridactrutask).datagrid('reload');
											$(gridactrutaskWaiting).datagrid('reload');
											$('#winactrutask').window('close');
										} else {
											var str = MESSAGE_PLAT.ERROR_SUBMIT
													+ flag.pageset.message;
											$.messager.alert(MESSAGE_PLAT.ERROR, str,
													'error');
										}
									});
						}
					});
				});
	});
	//-->
</script>